/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('umeng-finplus', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetCreditScoreRequest {
  appId?: long(name='AppId'),
  clientInfo?: string(name='ClientInfo'),
  extendInfo?: string(name='ExtendInfo'),
  idType?: string(name='IdType'),
  idValue?: string(name='IdValue'),
  reqId?: string(name='ReqId'),
  sign?: string(name='Sign'),
}

model GetCreditScoreResponseBody = {
  code?: int32(name='code', description='code'),
  message?: string(name='message'),
  response?: {
    bizId?: string(name='bizId'),
    reqId?: string(name='reqId'),
    tags?: map[string]any(name='tags'),
  }(name='response'),
  success?: boolean(name='success'),
}

model GetCreditScoreResponse = {
  headers: map[string]string(name='headers'),
  body: GetCreditScoreResponseBody(name='body'),
}

async function getCreditScore(request: GetCreditScoreRequest): GetCreditScoreResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getCreditScoreWithOptions(request, headers, runtime);
}

async function getCreditScoreWithOptions(request: GetCreditScoreRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetCreditScoreResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.appId)) {
    query['AppId'] = request.appId;
  }
  if (!Util.isUnset(request.clientInfo)) {
    query['ClientInfo'] = request.clientInfo;
  }
  if (!Util.isUnset(request.extendInfo)) {
    query['ExtendInfo'] = request.extendInfo;
  }
  if (!Util.isUnset(request.idType)) {
    query['IdType'] = request.idType;
  }
  if (!Util.isUnset(request.idValue)) {
    query['IdValue'] = request.idValue;
  }
  if (!Util.isUnset(request.reqId)) {
    query['ReqId'] = request.reqId;
  }
  if (!Util.isUnset(request.sign)) {
    query['Sign'] = request.sign;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetCreditScore',
    version = '2021-12-06',
    protocol = 'HTTPS',
    pathname = `/finplus/credit`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetMarketScoreRequest {
  appId?: long(name='AppId'),
  clientInfo?: string(name='ClientInfo'),
  extendInfo?: string(name='ExtendInfo'),
  idType?: string(name='IdType'),
  idValue?: string(name='IdValue'),
  reqId?: string(name='ReqId'),
  sign?: string(name='Sign'),
}

model GetMarketScoreResponseBody = {
  code?: int32(name='code', description='code'),
  message?: string(name='message'),
  response?: {
    bizId?: string(name='bizId'),
    reqId?: string(name='reqId'),
    tags?: map[string]any(name='tags'),
  }(name='response'),
  success?: boolean(name='success'),
}

model GetMarketScoreResponse = {
  headers: map[string]string(name='headers'),
  body: GetMarketScoreResponseBody(name='body'),
}

async function getMarketScore(request: GetMarketScoreRequest): GetMarketScoreResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getMarketScoreWithOptions(request, headers, runtime);
}

async function getMarketScoreWithOptions(request: GetMarketScoreRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetMarketScoreResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.appId)) {
    query['AppId'] = request.appId;
  }
  if (!Util.isUnset(request.clientInfo)) {
    query['ClientInfo'] = request.clientInfo;
  }
  if (!Util.isUnset(request.extendInfo)) {
    query['ExtendInfo'] = request.extendInfo;
  }
  if (!Util.isUnset(request.idType)) {
    query['IdType'] = request.idType;
  }
  if (!Util.isUnset(request.idValue)) {
    query['IdValue'] = request.idValue;
  }
  if (!Util.isUnset(request.reqId)) {
    query['ReqId'] = request.reqId;
  }
  if (!Util.isUnset(request.sign)) {
    query['Sign'] = request.sign;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetMarketScore',
    version = '2021-12-06',
    protocol = 'HTTPS',
    pathname = `/finplus/market`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

